package com.airbnb.mvrx.sample.features.clickread.views

import android.content.Context
import android.widget.FrameLayout
import android.widget.ImageView
import com.airbnb.epoxy.ModelProp
import com.airbnb.epoxy.ModelView
import com.airbnb.mvrx.sample.Utils
import com.bumptech.glide.Glide
import com.example.mvrxstudy.R

@ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT)
class CRContentItem @JvmOverloads constructor(
        context: Context)
    : FrameLayout(context) {

    private val mImage: ImageView

    init {
        inflate(context, R.layout.item_content_cr, this)
        mImage = findViewById(R.id.iv_image)
        mImage.layoutParams.height = Utils.getContentHeight(context) - Utils.dp2px(context, 62) - Utils.dp2px(context, 56)
    }

    @ModelProp
    fun setImage(thumb: String) {
        Glide.with(context)
                .load(thumb)
                .into(mImage)
    }

    @ModelProp
    fun setPosition(position: Int) {
        Utils.log("Content setPosition %d ", position)
    }

}